package com.caifeng.myapplication;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.ExpandableListView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;

import java.util.ArrayList;
import java.util.List;

public class Vfenzu extends Fragment {
    private View view;

//    private ExpandableListView ex;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.two_fenzu, null);
        init();
        return view;

    }

    private ExpandableListView expandableListView;

    private void init() {
        expandableListView = (ExpandableListView) view.findViewById(R.id.fenzu_list);
//            VfenzuAdapter vfenzuAdapter=
//                    new VfenzuAdapter(getData(),this);

//            expandableListView.setGroupIndicator(null);
        VfenzuAdapter vfenzuAdapter =
                new VfenzuAdapter(getData(), getActivity());
        expandableListView.setAdapter(vfenzuAdapter);


    }

    private List<VfenzuGroupBean> getData() {
        List<VfenzuGroupBean> mList = new ArrayList<>();


        VfenzuGroupBean vfenzuGroupBean = new VfenzuGroupBean();
//            vfenzuGroupBean
        vfenzuGroupBean.setGr_title("11");
        vfenzuGroupBean.setGr_online("2");
        vfenzuGroupBean.setGr_totalPerson("2");

        List<VfenzuGroupBean.VfenzuChildBean> childBeanList = new ArrayList<>();
        VfenzuGroupBean.VfenzuChildBean vfenzuChildBean = vfenzuGroupBean.new VfenzuChildBean();
        vfenzuChildBean.setAvatarid(R.mipmap.ala);
        vfenzuChildBean.setCh_name("Kelly");
        vfenzuChildBean.setCh_online("[WIFI在线]");
        vfenzuChildBean.setCh_text("morning");
        childBeanList.add(vfenzuChildBean);

        vfenzuChildBean = vfenzuGroupBean.new VfenzuChildBean();
        vfenzuChildBean.setAvatarid(R.mipmap.alb);
        vfenzuChildBean.setCh_name("Key");
        vfenzuChildBean.setCh_online("[4G在线]");
        vfenzuChildBean.setCh_text("111111...");
        childBeanList.add(vfenzuChildBean);

        vfenzuGroupBean.setmList(childBeanList);
        mList.add(vfenzuGroupBean);

        /**
         *第二个分组
         */
//        mList = new ArrayList<>();
        vfenzuGroupBean = new VfenzuGroupBean();
//            vfenzuGroupBean
        vfenzuGroupBean.setGr_title("12");
        vfenzuGroupBean.setGr_online("3");
        vfenzuGroupBean.setGr_totalPerson("3");

        childBeanList = new ArrayList<>();
        vfenzuChildBean = vfenzuGroupBean.new VfenzuChildBean();
        vfenzuChildBean.setAvatarid(R.mipmap.alc);
        vfenzuChildBean.setCh_name("Berry");
        vfenzuChildBean.setCh_online("[WIFI在线]");
        vfenzuChildBean.setCh_text("11");
        childBeanList.add(vfenzuChildBean);

        vfenzuChildBean = vfenzuGroupBean.new VfenzuChildBean();
        vfenzuChildBean.setAvatarid(R.mipmap.ald);
        vfenzuChildBean.setCh_name("Fine");
        vfenzuChildBean.setCh_online("[WIFI在线]");
        vfenzuChildBean.setCh_text("act pal");
        childBeanList.add(vfenzuChildBean);

        vfenzuChildBean = vfenzuGroupBean.new VfenzuChildBean();
        vfenzuChildBean.setAvatarid(R.mipmap.ale);
        vfenzuChildBean.setCh_name("FBI");
        vfenzuChildBean.setCh_online("[4G在线]");
        vfenzuChildBean.setCh_text("nove");
        childBeanList.add(vfenzuChildBean);

        vfenzuChildBean = vfenzuGroupBean.new VfenzuChildBean();
        vfenzuChildBean.setAvatarid(R.mipmap.ale);
        vfenzuChildBean.setCh_name("Kell");
        vfenzuChildBean.setCh_online("[4G在线]");
        vfenzuChildBean.setCh_text("nove");
        childBeanList.add(vfenzuChildBean);
        vfenzuChildBean = vfenzuGroupBean.new VfenzuChildBean();
        vfenzuChildBean.setAvatarid(R.mipmap.ale);
        vfenzuChildBean.setCh_name("qqonline");
        vfenzuChildBean.setCh_online("[4G在线]");
        vfenzuChildBean.setCh_text("nove");
        childBeanList.add(vfenzuChildBean);

        vfenzuGroupBean.setmList(childBeanList);
        mList.add(vfenzuGroupBean);

        return mList;

    }

}

